package com.dz.finance.api.controller;

import com.dz.finance.biz.dto.ClientDTO;
import com.dz.finance.biz.dto.PhoneRegisterDTO;
import com.dz.finance.biz.service.MemberRegisterService;
import com.dz.finance.biz.vo.GenerateMpRegCodeVo;
import com.dz.finance.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: DengHaoQi
 * @date: 2024/5/31 17:24
 * @description: 注册接口
 */

@Api(tags = "用户注册模块")
@RestController
@RequestMapping("/reg")
@RequiredArgsConstructor
@Slf4j
public class RegisterController {

    private final MemberRegisterService memberRegisterService;

    @ApiOperation("手机号注册")
    @PostMapping("/phoneReg")
    public Result<Long> phoneReg(@Validated @RequestBody PhoneRegisterDTO phoneRegisterDTO) {
        Long id = memberRegisterService.regPhone(phoneRegisterDTO);
        return Result.ok(id);
    }


    @ApiOperation("生成微信公众号二维码（关注注册）")
    @GetMapping("/generateMpRegCode")
    public Result<GenerateMpRegCodeVo> generateMpRegCode(@Validated @ModelAttribute ClientDTO clientDTO) {
        String clientId = clientDTO.getClientId();
        GenerateMpRegCodeVo generateMpRegCodeVo = memberRegisterService.generateMpRegCode(clientId);
        return Result.ok(generateMpRegCodeVo);
    }

}
